<?php
/*
 *  This file is part of Urd.
 *
 *  Urd is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  Urd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. See the file "COPYING". If it does not
 *  exist, see <http://www.gnu.org/licenses/>.
 *
 * $LastChangedDate: 2008-07-15 15:42:06 +0200 (Tue, 15 Jul 2008) $
 * $Rev: 1296 $
 * $Author: gavinspearhead $
 * $Id: browse.php 1296 2008-07-15 13:42:06Z gavinspearhead $
 */
if (!defined('ORIGINAL_PAGE')) define('ORIGINAL_PAGE', $_SERVER['PHP_SELF']);

$pathpg = realpath(dirname(__FILE__));


require_once "$pathpg/../functions/ajax_includes.php";

// TODO Challenge

if (!isset($_REQUEST['command'])) die('No command given');

$command = $_REQUEST['command'];

switch ($command) {
case 'setmenudisplay':
	$arg = GetArgument();
	$arg == 1 ? set_menu_display(1) : set_menu_display(0);
	break;
case 'setstatusdisplay':
	$arg = GetArgument();
	$arg == 1 ? set_status_display(1) : set_status_display(0);
	break;
case 'getstatusdisplay':
	echo get_status_display();
	break;
/*case 'getmenudisplay':
	echo get_menu_display();
	break;*/
default:	
	die('unknown command'); // no command, do nothing
}


die();
// We don't get beyond this, only functions:

function GetArgument()
{
	if (!isset($_REQUEST['arg'])) 
		die('no argument given');
	return $_REQUEST['arg'];
}


function set_menu_display($what)
{
	// 1 = show, 0 = hide
	$_SESSION['menudisplay'] = $what;
}


function set_status_display($what)
{
	// 1 = show, 0 = hide
	$_SESSION['statusdisplay'] = $what;
}

function get_status_display()
{
	if (!isset($_SESSION['statusdisplay'])) $_SESSION['statusdisplay'] = 1;
	return $_SESSION['statusdisplay'];
}

?>
